package com.smart.controller;

import com.smart.vo.UserVo;
import com.smart.common.util.SysUserDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author lgb
 * @date 2020年6月9日 上午10:18:13
 * Copyright (C) 深圳工勘科技
 * @说明: controller 基类
 **/
public abstract class BaseController {

	protected UserVo getCurrentUser() {
		try {
            SecurityContext ctx = SecurityContextHolder.getContext();
            Authentication auth = ctx.getAuthentication();
            SysUserDetails memberDetails = (SysUserDetails) auth.getPrincipal();
            return memberDetails.getInfoVo();
        } catch (Exception e) {
            return new UserVo();
        }
	}
	
}